Ext.namespace('VAS');

VAS.AdvancedSearchNumberField=Ext.extend(Ext.form.CompositeField,{
	initComponent : function() {
	 	var _this=this;

	 	var allowDecimals = true;
	 	//如果datadecimals为0，则只能输入整数。
	 	if(_this.datadecimals == 0){
	 		allowDecimals = false;
	 	}
	 	
	 	thisConfig={
	 		width :_this.width,
	        fieldLabel : _this.fieldLabel,
	        readOnly : _this.readOnly,
	        items : [
	        	{
					xtype: 'label',
					value: '&gt'
					,hideLabel  : true
					,width: 16
					,style :{
						paddingLeft : '8px'
					}
		        }
		        ,
		        {
				   id	: _this.name+'_gt',
	               name : _this.name+'_gt',
	               xtype: 'numberfield',
	               width: 70,
	               enableKeyEvents : true,
	               allowDecimals: allowDecimals,
	               decimalPrecision : _this.datadecimals
		        }
		        ,
		        {
					xtype: 'label',
					value: '&lt',
					width: 16
					,style :{
						paddingLeft : '8px'
					}
		        },
		        {
		           id	: _this.name+'_lt',
	               name : _this.name+'_lt',
	               
	               xtype: 'numberfield',
	               width: 70,
	               enableKeyEvents : true,
	               allowDecimals : allowDecimals,
	               decimalPrecision : _this.datadecimals
		        }
		        ,{
					xtype: 'label',
					value: '='
					,width: 16
					,style :{
						paddingLeft : '8px'
					}
		        },{
		            id : _this.name+'_eq',
					name : _this.name+'_eq',
					xtype: 'numberfield',
					width: 70,
					enableKeyEvents : true,
					allowDecimals : allowDecimals,
					decimalPrecision : _this.datadecimals
		        }
	        ]
	      };
	 	
		 Ext.apply(this, thisConfig);
		 Ext.apply(this.initialConfig, thisConfig);
		 VAS.AdvancedSearchNumberField.superclass.initComponent.apply(this,arguments);
	},
	onRender : function(ct,position){
		var _this=this;
		VAS.AdvancedSearchNumberField.superclass.onRender.call(this, ct, position);	
		var gt = Ext.getCmp(_this.name+'_gt');
	 	var it = Ext.getCmp(_this.name+'_lt');
	 	var eq = Ext.getCmp( _this.name+'_eq');
	 	gt.on('keyup',function(textfield,event){
	 		if(gt.getValue() != '' && it.getValue() != ''){
	 			eq.setValue('');
	 			eq.setDisabled(true);
	 		}else{
	 			eq.setDisabled(false);
	 		}
	 	});
	 	it.on('keyup',function(){
	 		if(gt.getValue() != '' && it.getValue() != ''){
	 			eq.setValue('');
	 			eq.setDisabled(true);
	 		}else{
	 			eq.setDisabled(false);
	 		}
	 	});
	}

});

Ext.reg('advancedSearch_numberfield',VAS.AdvancedSearchNumberField);